﻿using System;
using System.Data;
using LitJson;
using System.Collections.Generic;

/// <summary>
///AccountStatisticsProxy 的摘要说明
/// </summary>
public class AccountStatisticsProxy
{
	public AccountStatisticsProxy()
	{
		//
		//TODO: 在此处添加构造函数逻辑
		//
	}

    public void AddAccountStatistics(AccountStatistics account)
    {
        DBAccountStatistics accountStatistics = new DBAccountStatistics();
       
        accountStatistics.Add(account);
    }

    //获取某个账号一周的统计信息，返回一个JSON数组
    public string GetOneWeekAccountStatistics(string accountName)
    {
        if (accountName == null || accountName == "")
            return "";

        DBAccountStatistics accountStatistics = new DBAccountStatistics();
        List<AccountStatistics> list = accountStatistics.SelectList(accountName);
        JsonData json = new JsonData();
        json.SetJsonType(JsonType.Array);
        if (list.Count > 0)
        {
           
            for (int i = 0; i < list.Count; ++i)
            {
                JsonData jsonObj = list[i].toJsonObj();
                json.Add(jsonObj);
            }
        }
        else
        {
            return "";
        }

        return json.ToJson();
    }
}
